package com.carrot.uaa.util;


import com.carrot.uaa.constant.RedisConstants;

/**
 * redis工具类
 */
public class RedisUtils {

    /**
     * 拼接key
     * @param prefix
     * @param value
     * @return
     */
    public static String getKey(String prefix,String value){
        return prefix+value;
    }

    /**
     * 用户在线令牌key
     * @param value
     * @return
     */
    public static String getUserOnLineTokenKey(String value){
        return getKey(RedisConstants.USER_ON_LINE_TOKEN,value);
    }

    /**
     * 租户在线令牌key
     * @param value
     * @return
     */
    public static String getTenantOnLineTokenKey(String value){
        return getKey(RedisConstants.TENANT_ON_LINE_TOKEN,value);
    }

    /**
     * 在线刷新令牌key
     * @param value
     * @return
     */
    public static String getUserOnLineRefreshTokenKey(String value){
        return getKey(RedisConstants.USER_ON_LINE_TOKEN_REFRESH,value);
    }

    /**
     * 在线访问令牌key
     * @param value
     * @return
     */
    public static String getUserOnLineAccessTokenKey(String value){
        return getKey(RedisConstants.USER_ON_LINE_TOKEN_ACCESS,value);
    }

    /**
     * 认证日志key
     * @param value
     * @return
     */
    public static String getAuthorizationKey(String value){
        return getKey(RedisConstants.AUTHORIZATION,":"+value);
    }

    /**
     * 认证日志key
     * @param value
     * @return
     */
    public static String getAuthorizationAccessTokenIdxKey(String value){
        return getKey(RedisConstants.AUTHORIZATION_ACCESS_TOKEN_VALUE,value);
    }

    public static String getAuthorizationRefreshTokenIdxKey(String value){
        return getKey(RedisConstants.AUTHORIZATION_REFRESH_TOKEN_VALUE,value);
    }

    public static String getClientIdKey(String value){
        return getKey(RedisConstants.CLIENT_ID,value);
    }

    /**
     * 短信验证码key
     * @param value
     * @return
     */
    public static String getLoginSmsCaptchaKey(String value,String appName){
        return getKey(RedisConstants.LOGIN_SMS_CAPTCHA,appName+":"+value);
    }

    /**
     * 短信验证码发送次数key
     * @param value
     * @return
     */
    public static String getLoginSmsCaptchaCountKey(String value){
        return getKey(RedisConstants.LOGIN_SMS_CAPTCHA_COUNT,value);
    }

    /**
     * 短信验证码验证错误次数key
     * @param value
     * @return
     */
    public static String getLoginSmsCaptchaErrorCountKey(String value){
        return getKey(RedisConstants.LOGIN_SMS_CAPTCHA_ERROR_COUNT,value);
    }

    /**
     * 账号临时冻结状态key
     * @param value
     * @return
     */
    public static String getLoginTemporaryFreezeKey(String value){
        return getKey(RedisConstants.LOGIN_TEMPORARY_FREEZE,value);
    }

    /**
     * 密码验证错误次数key
     * @param value
     * @return
     */
    public static String getLoginPasswordErrorCountKey(String value){
        return getKey(RedisConstants.LOGIN_PASSWORD_ERROR_COUNT,value);
    }

}
